﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Yipusoft.Listener.Model;

public partial class BasicBase_Listenner_DutyCadreAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            Bind();
    }

    private void Bind()
    {
        string Dept = Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).DepartmentID;
        if (Dept == null || Dept.Length < 5)
            return;

        string strSql = "";
        if (Dept.Substring(0, 4).Equals("1300"))
            strSql += " 1=1";
        else
            strSql += " Left(DepartmentID,4)='" + Dept.Substring(0, 4) + "'";

        this.DptDepartment.DataSource = Yipusoft.Account.BLL.Department.GetList(strSql);
        this.DptDepartment.DataTextField = "FullName";
        this.DptDepartment.DataValueField = "DepartmentID";
        this.DptDepartment.DataBind();
      
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        lblPromt.Text = "";
        DutyCadreInfo info = new DutyCadreInfo();
        info.DateAdd=DateTime.Now;
        info.DepartmentID=DptDepartment.SelectedValue;
        info.DepartmentName=DptDepartment.SelectedItem.Text;
        info.SetUserID=Yipusoft.Account.BLL.User.GetUser(User.Identity.Name).UserID;
        info.UserID = Guid.NewGuid();
        info.UserName=txtUserName.Text.Trim();     
       

        if (Yipusoft.Listener.BLL.DutyCadre.Add(info) > 0)
        {
            lblPromt.Text = "添加成功";
        }
    }
}
